package yy.com.yjboview.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;

import yy.com.yjboview.R;

/**
 * @description: <描述当前版本功能>
 * <p>
 * </p>
 * @author: yjbo
 * @date: 2016-08-03 14:40
 */
public class dataAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    private static String[] names = null;
    static Activity mactivity;

    public dataAdapter(Activity activity, String[] listName) {
        mactivity = activity;
        names = listName;
        mInflater = mactivity.getLayoutInflater();

    }

    @Override
    public int getCount() {
        return names.length;
    }

    @Override
    public Object getItem(int position) {
        return names[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        View view = null;
        if (convertView != null) {
            view = convertView;
        } else {
            view = mInflater.inflate(R.layout.item_layout, parent, false);
        }
        final TextView tv_name = (TextView) view.findViewById(R.id.item_txt);

        tv_name.setText(names[position]);
        tv_name.setTag(position);

        return view;
    }

}
